{%- set image = "gcr.io/<project_id>/tf_std_data_server:latest" -%}
{%- set port = 5050 -%}
{% set ip_mapping = {
} %}

kind: ReplicaSet
apiVersion: apps/v1
metadata:
  name: data-service-dispatcher
spec:
  replicas: 1
  selector:
    matchLabels:
      name: data-service-dispatcher
  template:
    metadata:
      labels:
        name: data-service-dispatcher
    spec:
      containers:
      - name: tensorflow
        image: {{ image }}
        ports:
        - containerPort: {{ port }}
        args:
        - "--port={{ port }}"
        - "--is_dispatcher=true"
---

{% for worker_name, worker_ip in ip_mapping.items() %}
kind: ReplicaSet
apiVersion: extensions/v1beta1
metadata:
  name: {{ worker_name }}
spec:
  replicas: 1
  selector:
    matchLabels:
      name: {{ worker_name }}
  template:
    metadata:
      labels:
        name: {{ worker_name }}
    spec:
      containers:
      - name: tensorflow
        image: {{ image }}
        ports:
        - containerPort: {{ port }}
        args:
        - "--port={{ port }}"
        - "--is_dispatcher=false"
        - "--dispatcher_address=data-service-dispatcher:{{ port }}"
        - "--worker_address={{ worker_ip }}:{{ port }}"
---
{% endfor %}
